/******************************************************************************
	This file is a part of the Snapshot Bioinformatics Project

	Copyright (C) 2012-2013 Jarom Schow

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include "SeqLocation.h"

using namespace Bio;

/**
**/
SeqLocation::SeqLocation() : m_start( -1 ), m_end( -1 ), m_strand( Unknown )
{
}

/**
**/
SeqLocation::SeqLocation( int start, int end ) : m_start( start ), m_end( end ), m_strand( Unknown )
{
}

/**
**/
SeqLocation::SeqLocation( int start, int end, Strand strand ) : m_start( start ), m_end( end ),
	m_strand( strand )
{
}

/**
**/
SeqLocation::~SeqLocation()
{
}

/**
**/
int SeqLocation::getStart() const
{
	return m_start;
}

/**
**/
void SeqLocation::setStart( int start )
{
	m_start = start;
}

/**
**/
int SeqLocation::getEnd() const
{
	return m_end;
}

/**
**/
void SeqLocation::setEnd( int end )
{
	m_end = end;
}

/**
**/
SeqLocation::Strand SeqLocation::getStrand() const
{
	return m_strand;
}

/**
**/
void SeqLocation::setStrand( Strand strand )
{
	m_strand = strand;
}

/**
**/
void SeqLocation::switchStrand()
{
	if( m_strand == Positive )
		m_strand = Negative;
	else if( m_strand == Negative )
		m_strand = Positive;
}

/**
**/
QString SeqLocation::getReference() const
{
	return m_ref;
}

/**
**/
void SeqLocation::setReference( const QString &ref )
{
	m_ref = ref;
}

/**
**/
QString SeqLocation::getReferenceDb() const
{
	return m_refDb;
}

/**
**/
void SeqLocation::setReferenceDb( const QString &refDb )
{
	m_refDb = refDb;
}

/**
**/
QString SeqLocation::toString() const
{
	QString	str;

	if( !m_ref.isEmpty() )
		str = m_ref + ':';

	if( m_start == m_end )
		str += QString::number( m_start );
	else
		str += QString( "%1..%2" ).arg( m_start ).arg( m_end );

	if( m_strand == Positive )
		str += '+';
	else if( m_strand == Negative )
		str += '-';

	return str;
}
